home *** CD-ROM | disk | FTP | other *** search
- MScrollBarClass = function()
- {
- if(this._height == 4)
- {
- return undefined;
- }
- this.init();
- this.minPos = this.maxPos = this.pageSize = this.largeScroll = 0;
- this.smallScroll = 1;
- this.buttonHeight = 16;
- this.scrollThumbSymbol = "mScrollThumb";
- this.upArrowSymbol = "mUpArrow";
- this.downArrowSymbol = "mDownArrow";
- if(this.style == "Small")
- {
- this.buttonHeight = 12;
- this.scrollThumbSymbol = "mSmallScrollThumb";
- this.upArrowSymbol = "mSmallUpArrow";
- this.downArrowSymbol = "mSmallDownArrow";
- }
- this.width = !this.horizontal ? this._height : this._width;
- this._xscale = this._yscale = 100;
- this.setScrollPosition(0);
- this.tabEnabled = false;
- if(this._targetInstanceName.length > 0)
- {
- this.setScrollTarget(this._parent[this._targetInstanceName]);
- }
- this.tabChildren = false;
- this.setSize(this.width);
- };
- MScrollBarClass.prototype = new MUIComponentClass();
- MScrollBarClass.prototype.setHorizontal = function(flag)
- {
- if(this.horizontal && !flag)
- {
- this._xscale = 100;
- this._rotation = 0;
- }
- else if(flag && !this.horizontal)
- {
- this._xscale = -100;
- this._rotation = -90;
- }
- this.horizontal = flag;
- };
- MScrollBarClass.prototype.setScrollProperties = function(pSize, mnPos, mxPos)
- {
- if(!this.enable)
- {
- return undefined;
- }
- this.pageSize = pSize;
- this.minPos = Math.max(mnPos,0);
- this.maxPos = Math.max(mxPos,0);
- this.scrollPosition = Math.max(this.minPos,this.scrollPosition);
- this.scrollPosition = Math.min(this.maxPos,this.scrollPosition);
- if(this.maxPos - this.minPos <= 0)
- {
- this.scrollThumb_mc.removeMovieClip();
- if(this.style == "Small")
- {
- this.scrollTrack_mc.gotoAndStop("small_disabled");
- }
- else
- {
- this.scrollTrack_mc.gotoAndStop("disabled");
- }
- this.upArrow_mc.gotoAndStop("disabled");
- this.downArrow_mc.gotoAndStop("disabled");
- this.downArrow_mc.onPress = this.downArrow_mc.onRelease = this.downArrow_mc.onDragOut = null;
- this.upArrow_mc.onPress = this.upArrow_mc.onRelease = this.upArrow_mc.onDragOut = null;
- this.scrollTrack_mc.onPress = this.scrollTrack_mc.onRelease = null;
- this.scrollTrack_mc.onDragOut = this.scrollTrack_mc.onRollOut = null;
- this.scrollTrack_mc.useHandCursor = false;
- }
- else
- {
- var shadowOffset = 3;
- var tmp = this.getScrollPosition();
- if(this.style == "Small")
- {
- this.scrollTrack_mc.gotoAndStop("small_enabled");
- }
- else
- {
- this.scrollTrack_mc.gotoAndStop("enabled");
- }
- this.upArrow_mc.gotoAndStop("up");
- this.downArrow_mc.gotoAndStop("up");
- this.upArrow_mc.onPress = this.upArrow_mc.onDragOver = this.startUpScroller;
- this.upArrow_mc.onRelease = this.upArrow_mc.onDragOut = this.stopScrolling;
- this.upArrow_mc.onRollOver = this.rolloverScroller;
- this.upArrow_mc.onRollOut = this.upArrow_mc.onReleaseOutside = this.rolloutScroller;
- this.downArrow_mc.onPress = this.downArrow_mc.onDragOver = this.startDownScroller;
- this.downArrow_mc.onRelease = this.downArrow_mc.onDragOut = this.stopScrolling;
- this.downArrow_mc.onRollOver = this.rolloverScroller;
- this.downArrow_mc.onRollOut = this.downArrow_mc.onReleaseOutside = this.rolloutScroller;
- this.scrollTrack_mc.onPress = this.scrollTrack_mc.onDragOver = this.startTrackScroller;
- this.scrollTrack_mc.onRelease = this.stopScrolling;
- this.scrollTrack_mc.onDragOut = this.stopScrolling;
- this.scrollTrack_mc.onRollOut = this.stopScrolling;
- this.scrollTrack_mc.useHandCursor = false;
- this.attachMovie(this.scrollThumbSymbol,"scrollThumb_mc",3);
- this.scrollThumb_mc._x = 0;
- this.scrollThumb_mc._y = this.buttonHeight - shadowOffset;
- this.scrollThumb_mc.onPress = this.startDragThumb;
- this.scrollThumb_mc.controller = this;
- this.scrollThumb_mc.onRelease = this.scrollThumb_mc.onReleaseOutside = this.stopDragThumb;
- this.scrollThumb_mc.onRollOver = this.rolloverThumb;
- this.scrollThumb_mc.onRollOut = this.rolloutThumb;
- this.scrollThumb_mc.onDragOut = this.dragoutThumb;
- this.scrollThumb_mc.useHandCursor = false;
- var trackSize = this.width - this.buttonHeight * 2;
- this.thumbHeight = this.pageSize / (this.maxPos - this.minPos + this.pageSize) * trackSize;
- this.thumbMid_mc = this.scrollThumb_mc.mc_sliderMid;
- this.thumbTop_mc = this.scrollThumb_mc.mc_sliderTop;
- this.thumbBot_mc = this.scrollThumb_mc.mc_sliderBot;
- this.thumbGrips = this.scrollThumb_mc.grips;
- this.thumbHeight = Math.max(this.thumbHeight,26);
- this.midHeight = this.thumbHeight - 10;
- this.thumbMid_mc._yScale = this.midHeight * 100 / this.thumbMid_mc._height;
- this.thumbMid_mc._y = 5 - shadowOffset;
- this.thumbGrips._y = Math.floor(this.thumbHeight / 2 - this.thumbGrips._height / 2 - shadowOffset / 2);
- if(this.thumbHeight < 20)
- {
- this.thumbGrips._visible = false;
- }
- this.thumbBot_mc._y = 5 + this.midHeight - shadowOffset;
- this.scrollTop = this.scrollThumb_mc._y + shadowOffset;
- this.trackHeight = trackSize - this.thumbHeight + shadowOffset;
- this.scrollBot = this.trackHeight + this.scrollTop;
- tmp = Math.min(tmp,this.maxPos);
- this.setScrollPosition(Math.max(tmp,this.minPos));
- }
- };
- MScrollBarClass.prototype.getScrollPosition = function()
- {
- return this.scrollPosition;
- };
- MScrollBarClass.prototype.setScrollPosition = function(pos)
- {
- this.scrollPosition = pos;
- if(this.scrollThumb_mc != undefined)
- {
- pos = Math.min(pos,this.maxPos);
- pos = Math.max(pos,this.minPos);
- }
- this.scrollThumb_mc._y = Math.round((pos - this.minPos) * this.trackHeight / (this.maxPos - this.minPos)) + this.scrollTop;
- this.executeCallBack();
- };
- MScrollBarClass.prototype.setLargeScroll = function(lScroll)
- {
- this.largeScroll = lScroll;
- };
- MScrollBarClass.prototype.setSmallScroll = function(sScroll)
- {
- this.smallScroll = sScroll;
- };
- MScrollBarClass.prototype.setEnabled = function(enabledFlag)
- {
- var wasEnabled = this.enable;
- if(enabledFlag && !wasEnabled)
- {
- this.enable = enabledFlag;
- if(this.textField != undefined)
- {
- this.setScrollTarget(this.textField);
- }
- else
- {
- this.setScrollProperties(this.pageSize,this.cachedMinPos,this.cachedMaxPos);
- this.setScrollPosition(this.cachedPos);
- }
- this.clickFilter = undefined;
- }
- else if(!enabledFlag && wasEnabled)
- {
- this.textField.removeListener(this);
- this.cachedPos = this.getScrollPosition();
- this.cachedMinPos = this.minPos;
- this.cachedMaxPos = this.maxPos;
- if(this.clickFilter == undefined)
- {
- this.setScrollProperties(this.pageSize,0,0);
- }
- else
- {
- this.clickFilter = true;
- }
- this.enable = enabledFlag;
- }
- };
- MScrollBarClass.prototype.getStyle = function()
- {
- return this.style;
- };
- MScrollBarClass.prototype.setStyle = function(style)
- {
- this.style = style.toLowerCase() != "small" ? "Normal" : "Small";
- this.buttonHeight = 16;
- this.scrollThumbSymbol = "mScrollThumb";
- this.upArrowSymbol = "mUpArrow";
- this.downArrowSymbol = "mDownArrow";
- if(this.style == "Small")
- {
- this.buttonHeight = 12;
- this.scrollThumbSymbol = "mSmallScrollThumb";
- this.upArrowSymbol = "mSmallUpArrow";
- this.downArrowSymbol = "mSmallDownArrow";
- }
- this.upArrow_mc.removeMovieClip();
- this.downArrow_mc.removeMovieClip();
- this.setSize(this.width - 1);
- };
- MScrollBarClass.prototype.setSize = function(hgt)
- {
- if(this._height == 1)
- {
- return undefined;
- }
- this.width = hgt + 1;
- this.scrollTrack_mc._yscale = 100;
- this.scrollTrack_mc._yscale = 100 * this.width / this.scrollTrack_mc._height;
- if(this.upArrow_mc == undefined)
- {
- this.attachMovie(this.upArrowSymbol,"upArrow_mc",1);
- this.attachMovie(this.downArrowSymbol,"downArrow_mc",2);
- this.downArrow_mc.controller = this.upArrow_mc.controller = this;
- this.upArrow_mc.useHandCursor = this.downArrow_mc.useHandCursor = false;
- this.upArrow_mc._x = this.upArrow_mc._y = 0;
- this.downArrow_mc._x = 0;
- }
- this.scrollTrack_mc.controller = this;
- this.downArrow_mc._y = this.width - this.buttonHeight;
- if(this.textField != undefined)
- {
- this.onTextChanged();
- }
- else
- {
- this.setScrollProperties(this.pageSize,this.minPos,this.maxPos);
- }
- this.scrollTrack_mc.topShad._yscale = 100;
- this.scrollTrack_mc.topShad._xscale = 100;
- this.scrollTrack_mc.topShad._y = this.scrollTrack_mc._y + 8;
- this.scrollTrack_mc.botShad._yscale = 100;
- this.scrollTrack_mc.botShad._xscale = 100;
- this.scrollTrack_mc.botShad._y = this.downArrow_mc._y - 8;
- };
- MScrollBarClass.prototype.scrollIt = function(inc, mode)
- {
- var delt = this.smallScroll;
- if(inc != "one")
- {
- delt = this.largeScroll != 0 ? this.largeScroll : this.pageSize;
- }
- var newPos = this.getScrollPosition() + mode * delt;
- if(newPos > this.maxPos)
- {
- newPos = this.maxPos;
- }
- else if(newPos < this.minPos)
- {
- newPos = this.minPos;
- }
- this.setScrollPosition(newPos);
- };
- MScrollBarClass.prototype.startDragThumb = function()
- {
- this.mc_sliderTop.gotoAndStop("down");
- this.mc_sliderBot.gotoAndStop("down");
- this.mc_sliderMid.gotoAndStop("down");
- this.grips.gotoAndStop("down");
- this.lastY = this._ymouse;
- this.onMouseMove = this.controller.dragThumb;
- };
- MScrollBarClass.prototype.dragThumb = function()
- {
- this.scrollMove = this._ymouse - this.lastY;
- this.scrollMove += this._y;
- if(this.scrollMove < this.controller.scrollTop)
- {
- this.scrollMove = this.controller.scrollTop;
- }
- else if(this.scrollMove > this.controller.scrollBot)
- {
- this.scrollMove = this.controller.scrollBot;
- }
- this._y = this.scrollMove;
- var c = this.controller;
- c.scrollPosition = Math.round((c.maxPos - c.minPos) * (this._y - c.scrollTop) / c.trackHeight) + c.minPos;
- this.controller.isScrolling = true;
- updateAfterEvent();
- this.controller.executeCallBack();
- };
- MScrollBarClass.prototype.stopDragThumb = function()
- {
- var upState = "up";
- if(this.mouseOver)
- {
- upState = "over";
- }
- this.mc_sliderTop.gotoAndStop(upState);
- this.mc_sliderBot.gotoAndStop(upState);
- this.mc_sliderMid.gotoAndStop(upState);
- this.grips.gotoAndStop(upState);
- this.controller.isScrolling = false;
- this.onMouseMove = null;
- };
- MScrollBarClass.prototype.rolloverThumb = function()
- {
- this.mouseOver = true;
- this.mc_sliderTop.gotoAndStop("over");
- this.mc_sliderBot.gotoAndStop("over");
- this.mc_sliderMid.gotoAndStop("over");
- this.grips.gotoAndStop("over");
- };
- MScrollBarClass.prototype.rolloutThumb = function()
- {
- this.mouseOver = false;
- this.mc_sliderTop.gotoAndStop("up");
- this.mc_sliderBot.gotoAndStop("up");
- this.mc_sliderMid.gotoAndStop("up");
- this.grips.gotoAndStop("up");
- };
- MScrollBarClass.prototype.dragoutThumb = function()
- {
- this.mouseOver = false;
- };
- MScrollBarClass.prototype.startTrackScroller = function()
- {
- this.controller.trackScroller();
- this.controller.scrolling = setInterval(this.controller,"scrollInterval",500,"page",-1);
- };
- MScrollBarClass.prototype.scrollInterval = function(inc, mode)
- {
- clearInterval(this.scrolling);
- if(inc == "page")
- {
- this.trackScroller();
- }
- else
- {
- this.scrollIt(inc,mode);
- }
- this.scrolling = setInterval(this,"scrollInterval",35,inc,mode);
- };
- MScrollBarClass.prototype.trackScroller = function()
- {
- if(this.scrollThumb_mc._y + this.thumbHeight < this._ymouse)
- {
- this.scrollIt("page",1);
- }
- else if(this.scrollThumb_mc._y > this._ymouse)
- {
- this.scrollIt("page",-1);
- }
- };
- MScrollBarClass.prototype.stopScrolling = function()
- {
- if(this.controller.downArrow_mc.mouseOver)
- {
- this.controller.downArrow_mc.gotoAndStop("over");
- }
- else
- {
- this.controller.downArrow_mc.gotoAndStop("up");
- }
- if(this.controller.upArrow_mc.mouseOver)
- {
- this.controller.upArrow_mc.gotoAndStop("over");
- }
- else
- {
- this.controller.upArrow_mc.gotoAndStop("up");
- }
- clearInterval(this.controller.scrolling);
- };
- MScrollBarClass.prototype.startUpScroller = function()
- {
- this.controller.upArrow_mc.gotoAndStop("down");
- this.controller.scrollIt("one",-1);
- this.controller.scrolling = setInterval(this.controller,"scrollInterval",500,"one",-1);
- };
- MScrollBarClass.prototype.startDownScroller = function()
- {
- this.controller.downArrow_mc.gotoAndStop("down");
- this.controller.scrollIt("one",1);
- this.controller.scrolling = setInterval(this.controller,"scrollInterval",500,"one",1);
- };
- MScrollBarClass.prototype.rolloverScroller = function()
- {
- this.mouseOver = true;
- this.gotoAndStop("over");
- };
- MScrollBarClass.prototype.rolloutScroller = function()
- {
- this.mouseOver = false;
- this.gotoAndStop("up");
- };
- MScrollBarClass.prototype.setScrollTarget = function(tF)
- {
- if(tF == undefined)
- {
- this.textField.removeListener(this);
- delete this.textField[!this.horizontal ? "vScroller" : "hScroller"];
- if(this.textField.hScroller != undefined && this.textField.vScroller != undefined)
- {
- this.textField.unwatch("text");
- this.textField.unwatch("htmltext");
- }
- }
- this.textField = undefined;
- if(!(tF instanceof TextField))
- {
- return undefined;
- }
- this.textField = tF;
- this.textField[!this.horizontal ? "vScroller" : "hScroller"] = this;
- this.onTextChanged();
- this.onChanged = function()
- {
- this.onTextChanged();
- };
- this.onScroller = function()
- {
- if(!this.isScrolling)
- {
- if(!this.horizontal)
- {
- this.setScrollPosition(this.textField.scroll);
- }
- else
- {
- this.setScrollPosition(this.textField.hscroll);
- }
- }
- };
- this.textField.addListener(this);
- this.textField.watch("text",this.callback);
- this.textField.watch("htmlText",this.callback);
- };
- MScrollBarClass.prototype.callback = function(prop, oldVal, newVal)
- {
- clearInterval(this.hScroller.synchScroll);
- clearInterval(this.vScroller.synchScroll);
- this.hScroller.synchScroll = setInterval(this.hScroller,"onTextChanged",50);
- this.vScroller.synchScroll = setInterval(this.vScroller,"onTextChanged",50);
- return newVal;
- };
- MScrollBarClass.prototype.onTextChanged = function()
- {
- if(!this.enable || this.textField == undefined)
- {
- return undefined;
- }
- clearInterval(this.synchScroll);
- if(this.horizontal)
- {
- var pos = this.textField.hscroll;
- this.setScrollProperties(this.textField._width,0,this.textField.maxhscroll);
- this.setScrollPosition(Math.min(pos,this.textField.maxhscroll));
- }
- else
- {
- var pos = this.textField.scroll;
- var pageSize = this.textField.bottomScroll - this.textField.scroll;
- this.setScrollProperties(pageSize,1,this.textField.maxscroll);
- this.setScrollPosition(Math.min(pos,this.textField.maxscroll));
- }
- };
- MScrollBarClass.prototype.executeCallBack = function()
- {
- if(this.textField == undefined)
- {
- super.executeCallBack();
- }
- else if(this.horizontal)
- {
- this.textField.hscroll = this.getScrollPosition();
- }
- else
- {
- this.textField.scroll = this.getScrollPosition();
- }
- };
- Object.registerClass("MScrollBarSymbol",MScrollBarClass);
-